#include <stdio.h>
#include <stdlib.h>
#include "DefaultUtils.h"
#include "DComplier.h"
#include "DataMessage.h"
#include "HandleMessage.h"
#include "SStates.h"

#define LENGTH_COMMOND 256


int main()
{
    printf("Start client...\n");
    int iLengthofCommond;
    char pcCommond[LENGTH_COMMOND];
    SStates sStates;
    SStatesInit(&sStates);
    SDataMessage sMsg;
    RefreshMessage(&sMsg,&sStates);
    printf("Welcome to V-FTP system.\nYou can get help by ?\n");

    while(SStatesIsClientWorking(&sStates))
    {
        RefreshBuffer(&pcCommond[0],LENGTH_COMMOND);
        RefreshMessage(&sMsg,&sStates);
        printf(">>");
        //读取用户输入

        if(fgets(pcCommond,sizeof(pcCommond),stdin))
        {
            iLengthofCommond = strlen(pcCommond);
            if(!AnalyMessage(&sMsg,pcCommond,iLengthofCommond))
                continue;
            DispatchMessage(&sMsg,&sStates);
        }
    }
    return 0;
}


